

import numpy as np
import pickle
import pprint


# fold_list1 = np.load('/data-disk/dingj/fold_list.npy')
# fold_list2 = np.load('/data-disk/dingj/fold_list_kaggle.npy') # fold_list[0]=kaggle_beni fold[1]=kaggle_test fold[2]=spie

# fold_list = np.load('/data-disk/dingj/fold_list_all.npy')
pkl_file = open('/data_4t/Kaggle/submission_code_data/data/faster_rcnn_candidates_bak/candis_v15_stage2.pkl', 'rb')
data1 = pickle.load(pkl_file)

pkl_file = open('/data-disk/Kaggle/candidates/candidates_kaggle_testset_with_lungmask_0330.pkl', 'rb')
data2 = pickle.load(pkl_file)

flip_list = np.load('/data_4t/Kaggle/submission_code_data/code/faster_rcnn_candidates/flip_list.npy')

for cdd in data1:
    if cdd['scanid'][0:4] == '8f51':
        print '{:5.1d, :5.1d, :5.1d, :5.1d, :5.1d, :5.1d}'.format(cdd['bbox'][0], cdd['bbox'][1], cdd['bbox'][2], cdd['bbox'][3], cdd['bbox'][4], cdd['bbox'][5])

print '------------------------------'
for cdd in data2:
    if cdd['scanid'][0:4] == '8f51':
        print '{:5.1d, :5.1d, :5.1d, :5.1d, :5.1d, :5.1d}'.format(cdd['bbox'][0], cdd['bbox'][1], cdd['bbox'][2], cdd['bbox'][3],
                                                       cdd['bbox'][4], cdd['bbox'][5])

error_list = []
idx = 0
# for cdd1 in data1:
#     print idx
#     idx = idx + 1
#     if cdd1['scan_id'] in flip_list:
#         continue
#     bbox1 = cdd1['bbox']
#     flag = False
#     for cdd2 in data2:
#         if cdd2['scan_id'] == cdd1['scan_id']:
#             bbox2 = cdd2['bbox']
#             if bbox1[0] == bbox2[0] and \
#                bbox1[1] == bbox2[1] and \
#                bbox1[2] == bbox2[2] and \
#                bbox1[3] == bbox2[3] and \
#                bbox1[4] == bbox2[4] and \
#                bbox1[5] == bbox2[5]:
#                 flag = True
#                 break
#     if not flag:
#         error_list.append(cdd1['scan_id'])
#     pass

label_dict = np.load('/data_4t/Kaggle/backup/kaggle/label_dict_0325.npy').item()
dict_isfound = {}
for scan_name in label_dict.keys():
    dict_isfound[scan_name] = np.zeros(len(label_dict[scan_name]))

for cdd1 in data1:
    scan_name = cdd1['scan_id']
    if scan_name in flip_list:
        continue


    pass

pass

